<?php
namespace app\index\model;
use think\captcha\Captcha;
use think\Model;
use think\Db;
class Admin extends Model{
    public function login($data){

        $captcha = new Captcha();
        if(!$captcha->check($data['vercode'])){
            return 4;
        }
        $list= [
    		'username' => $data['username'],
    		'password' => md5($data['password']),
    	];
        $user = Db::name('user')->where($list)->find();
        if($user){
            if($user['password'] == md5($data['password'])){
                session('username', $user['username']);
                session('uid', $user['id']);
                return 3;
            }else{
                return 2;//密码错误
            }
        }else{
            return 1; //用户不存在
        }
    }
}


?>